Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding optional CUDA DLLs when installing onnxruntime_gpu #22506

Open
wants to merge 49 commits into
base: main
Choose a base branch
from

Conversation

jchen351
Copy link
Contributor

Description

This code change enable user to install Nvidia CUDA DLLs when installing onnxruntime_gpu. with pip install onnxruntime_gpu[cuda_dlls].

It will also enable onnxruntime_gpu to use dynamic libraries under site-packages/nvidia that contain .dll files for Windows and .so files for Linux by temporary updating the environmental variables within an ORT Inferencing session.

Motivation and Context

Request by

setup.py Show resolved Hide resolved
@snnn snnn requested a review from jywu-msft October 22, 2024 01:16
@snnn
Copy link
Member

snnn commented Oct 23, 2024

There are some test failures, Please fix them. We will remove the "orttraining-linux-gpu-ci-pipeline". The others still need to be taking care of.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can commit the suggested changes from lintrunner.

onnxruntime/python/onnxruntime_cuda_temp_env.py Outdated Show resolved Hide resolved
@jchen351 jchen351 requested a review from tianleiwu November 7, 2024 22:31
@jchen351 jchen351 closed this Nov 11, 2024
@jchen351 jchen351 requested a review from tianleiwu December 12, 2024 18:48
onnxruntime/__init__.py Fixed Show fixed Hide fixed
onnxruntime/__init__.py Outdated Show resolved Hide resolved
onnxruntime/__init__.py Outdated Show resolved Hide resolved
onnxruntime/__init__.py Outdated Show resolved Hide resolved
onnxruntime/__init__.py Outdated Show resolved Hide resolved
@jchen351 jchen351 requested a review from tianleiwu December 16, 2024 20:27
onnxruntime/__init__.py Outdated Show resolved Hide resolved
@jchen351 jchen351 requested a review from tianleiwu December 17, 2024 02:05
onnxruntime/__init__.py Outdated Show resolved Hide resolved
onnxruntime/__init__.py Outdated Show resolved Hide resolved
@jchen351 jchen351 requested a review from tianleiwu December 19, 2024 03:53
setup.py Outdated
if cuda_version:
f.write(f"cuda_version = '{cuda_version}'\n")
# cudart_versions are integers
cudart_versions = find_cudart_versions(build_env=True)
Copy link
Contributor

@tianleiwu tianleiwu Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

find_cudart_versions only works on Linux. I think we can add a check of linux before calling find_cudart_versions to avoid a warning message in Windows.



# Load nvidia libraries from site-packages/nvidia if the package is onnxruntime-gpu
if cuda_version is not None and cuda_version != "":
Copy link
Contributor

@tianleiwu tianleiwu Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my test, cuda_version is still empty string. It is imported from onnxruntime.capi.onnxruntime_validation in line 73. That class only outputs cuda_version for training as below:

cuda_version = ""
if has_ortmodule:

We can remove the line of if has_ortmodule there.

@jchen351 jchen351 requested a review from tianleiwu December 22, 2024 02:33

try: # noqa: SIM105
from .build_and_package_info import cuda_version
except Exception:

Check notice

Code scanning / CodeQL

Empty except Note

'except' clause does nothing but pass and there is no explanatory comment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants